home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 2
/
Gold Medal Software Volume 2 (Gold Medal) (1994).iso
/
prog
/
memomous.arj
/
MEMOMOUS.PRG
next >
Wrap
Text File
|
1993-09-16
|
5KB
|
180 lines
*Copyright 1993 Robert Greenlee, 72677,517, (619) 268-0112. Distribute Freely.
*An example of a moused memoedit for Clipper 5.xx
*Uses mouse primitives in Nanforum ToolKit v2.1.
*Compile/Link: Clipper memomous. Blinker fi memomous LIB NANFOR.
* or RTLink fi memomous LIB NANFOR.
#include "inkey.ch"
#include "memoedit.ch"
IF ! FT_MINIT()
? "Can't run this mousey demo without a mouse!"
QUIT
ENDI
setcolor(IF(ISCOLOR(),'BG+/B','GR/N'))
FT_MSETCOORD( maxrow(), 0 )
IF !FILE("memomous.dbt")
aDbf :={{"Top","N",2,0},{"Bot","N",2,0},{"RCol","N",3,0},;
{"LCol","N",3,0},{"mText","M",0,0}}
dbCreate("memomous",aDbf) ; USE memomous ALIAS my ; APPEND BLANK
my->Top := 1 ; my->Bot := maxrow()-1 ; my->RCol := maxcol()-1
my->LCol := 1 ; cText := ''
FOR x = 1 TO 200 ; cText += LTRIM(STR(x,3))+CHR(13)+CHR(10) ; NEXT
my->mText := cText
ENDI
USE memomous ALIAS my
SET KEY K_F1 TO funcF1
cText := my->mText
reedit := .t.
DO WHIL reedit
cText := MEMOEDIT(cText,my->Top+1,my->LCol+2,my->Bot-1,my->RCol-1,.T.,;
"textFunc",my->RCol-my->LCol-3,5)
ENDD
CLEAR
@ 24,0 SAY 'You just moused memoedit! '
IF ! LASTKEY() = K_ESC
my->mText := cText
?? 'Your changes were saved.'
ELSE
?? 'No text changes made.'
ENDI
RETURN
FUNC textFunc(mode,LINE,COL)
LOCAL keypress,retval,mtop,mbot,mfakekey,oldBot,oldRCol
oldBot := my->Bot ; oldRCol := my->RCol
mfakekey := K_CTRL_Z ; keypress := LASTKEY() ; retval := 0
IF mode = ME_INIT
reedit := .f.
CLEAR
@ 0,2 SAY 'F1=Help'
@ 0,34 SAY 'MOUSEY MEMOEDIT'
@ 0,maxcol()-5 SAY 'PgUp'
@ maxrow(),maxcol()-5 SAY 'PgDn'
@ ROW(),2 SAY 'F10=Save ESC=Undo'
@ my->Top,my->LCol TO my->Bot,my->RCol DOUBLE
ELSEIF mode = ME_IDLE
nRow := ROW() ; nCol := COL() ; SetCursor(0)
@ maxrow(),34 SAY 'Line: '+PADR(LTRIM(STR(LINE)),4)
@ ROW(),45 SAY 'Col: '+PADR(LTRIM(STR(COL)),3)
@ nRow,nCol SAY '' ; SetCursor(1)
memomouse()
IF ! (oldBot = my->Bot .AND. oldRCol = my->RCol) // redraw box
reedit := .t.
KEYBOARD CHR(K_CTRL_W)+CHR(mfakekey)
ENDI
ELSE
IF keypress = mfakekey
memomouse()
IF ! (oldBot = my->Bot .AND. oldRCol = my->RCol) // redraw box
reedit := .t.
KEYBOARD CHR(K_CTRL_W)+CHR(mfakekey)
ENDI
ENDI
IF keypress = K_F10
retval = K_CTRL_W
ENDI
IF NEXTKEY() = 0
KEYBOARD(CHR(mfakekey))
ENDI
ENDI
RETURN retval
FUNCTION memomouse()
LOCAL nX,nY,cK,key_blk,nKey
FT_MCURSOR(.t.) // mouse cursor on
nKey := NEXTKEY()
DO WHIL ! FT_MBUTPRS() = 0 // wait for button release from last time
ENDD
DO WHIL nKey = 0
nX := FT_MGETX() ; nY := FT_MGETY()
IF FT_MBUTPRS() = 2
my->Bot := nX
my->RCol := nY
DO WHIL FT_MBUTPRS() = 2 // wait for it to be released
ENDD
INKEY(.1) // let it settle down
EXIT
ENDI
IF FT_MBUTPRS() = 1
IF nX == my->Top
KEYBOARD REPLI(CHR(K_UP),ROW()-my->Top)
ELSEIF nX < my->Top
KEYBOARD CHR(K_PGUP)
ELSEIF nX == my->Bot
KEYBOARD REPLI(CHR(K_DOWN),my->Bot-ROW())
ELSEIF nX > my->Bot
KEYBOARD CHR(K_PGDN)
ELSE
cK := ''
IF nX < ROW()
cK += REPLI(CHR(K_UP),ROW()-nX)
ELSEIF nX > ROW()
cK += REPLI(CHR(K_DOWN),nX-ROW())
ENDI
IF nY < COL()
cK += REPLI(CHR(K_LEFT),COL()-nY)
ELSEIF nY > COL()
cK += REPLI(CHR(K_RIGHT),nY-COL())
ENDI
IF !EMPTY(cK)
KEYBOARD cK
ENDI
ENDI
ENDI
nKey := NEXTKEY() // don't let memoedit eval any setkey's
IF ! nKey = 0 .AND. (key_blk := setkey(nKey)) != Nil
INKEY()
FT_MCURSOR(.f.) // mouse cursor off
EVAL(key_blk, procname(2), procline(2), "")
FT_MCURSOR(.t.) // mouse cursor on
nKey := NEXTKEY()
LOOP
ENDI
ENDD
FT_MCURSOR(.f.) // mouse cursor off
RETURN Nil
FUNCTION funcF1
LOCAL oldF1,scr1,nRow,nCol
oldF1 := SETKEY(K_F1,Nil) // disable F1
SAVE SCREEN TO scr1
nRow := ROW() ; nCol := COL() ; SetCursor(0)
CLEAR
TEXT
-- The Help Screen --
A SetKey Function (F1) has just been EVALed in the memoedit mouse handler
in order to prevent memoedit from gaining control.
Using the mouse you can:
* Position the cursor inside the memo box by pointing and clicking.
* PgUp by clicking outside the memo box at the top.
* PgDn by clicking outside the memo box at the bottom.
* LineUp by clicking on the top line of the memo box.
* LineDn by clicking on the bottom line of the memo box.
* Resize the box by pointing and clicking with the right button.
ENDTEXT
@ maxrow()-3,24 SAY '-- Touch any key or go Click --'
@ maxrow()-1,2 SAY 'Copyright 1993 Robert Greenlee, 72677,517, (619)268-0112, Distribute Freely.'
@ 0,0 TO maxrow(),maxcol() DOUBLE
DO WHIL INKEY() + FT_MBUTPRS() = 0
ENDD
DO WHIL ! FT_MBUTPRS() = 0 // wait for button release
ENDD
INKEY(.1) // wait for mouse button to settle down
RESTORE SCREEN FROM scr1
@ nRow,nCol SAY ''
SetCursor(1)
SETKEY(K_F1,oldF1) // reenable F1
RETURN Nil